some basic unittests

This commit is contained in:
Jurriaan Bremer
2016-08-23 02:51:08 +02:00
parent 161c37a321
commit 6505d3263f
3 changed files with 37 additions and 2 deletions
+12 -1
View File
@@ -6,7 +6,7 @@
import pytest
import tempfile
from cuckoo.common.config import Config
from cuckoo.common.config import Config, parse_options, emit_options
from cuckoo.common.exceptions import CuckooOperationalError
from cuckoo.misc import set_cwd
@@ -48,3 +48,14 @@ class TestConfig:
self.c = Config("bar")
with pytest.raises(CuckooOperationalError):
self.c.get("foo")
def test_options(self):
assert parse_options("a=b") == {"a": "b"}
assert parse_options("a=b,b=c") == {"a": "b", "b": "c"}
assert emit_options({"a": "b"}) == "a=b"
assert emit_options({"a": "b", "b": "c"}).count(",") == 1
assert "a=b" in emit_options({"a": "b", "b": "c"})
assert "b=c" in emit_options({"a": "b", "b": "c"})
assert parse_options(emit_options({"x": "y"})) == {"x": "y"}
+18
View File
@@ -0,0 +1,18 @@
# Copyright (C) 2010-2013 Claudio Guarnieri.
# Copyright (C) 2014-2016 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
from cuckoo.common.netlog import (
pointer_converter_32bit, pointer_converter_64bit
)
def test_pointer_repr():
assert pointer_converter_32bit(0) == "0x00000000"
assert pointer_converter_32bit(1) == "0x00000001"
assert pointer_converter_32bit(0xffffffff) == "0xffffffff"
assert pointer_converter_64bit(0) == "0x0000000000000000"
assert pointer_converter_64bit(1) == "0x0000000000000001"
assert pointer_converter_64bit(0xffffffff) == "0x00000000ffffffff"
assert pointer_converter_64bit(0xffffffffffffffff) == "0xffffffffffffffff"
+7 -1
View File
@@ -5,9 +5,10 @@
import os
import pytest
import re
import tempfile
from cuckoo.common.objects import Dictionary, File
from cuckoo.common.objects import Dictionary, File, URL_REGEX
class TestDictionary:
def setup_method(self, method):
@@ -75,3 +76,8 @@ class TestFile:
def teardown(self):
os.remove(self.path)
def test_regex():
r = re.findall(URL_REGEX, "foo http://google.com/search bar")
assert len(r) == 1
assert "".join(r[0]) == "http://google.com/search"