Example #1
0
    def test_server_chain_repository_creation(self):
        settings = OrmucoCacheServerSettings()
        settings.peers.add(OrmucoServerSettings("localhost", 11142))

        repository = RepositoryFactory.build_repository(settings)

        self.assertIsInstance(repository, ChainServerRepository)
    def test_retrieve_command_test(self):
        settings = OrmucoCacheServerSettings()

        command_parser = CommandParser(settings)

        retrieve_command = "RTRV " + str(uuid.uuid4())
        result = command_parser.parse(retrieve_command)
        self.assertEqual(result, None)
    def test_miss_parsing(self):
        settings = OrmucoCacheServerSettings()

        command_parser = CommandParser(settings)

        command = "MISS"
        result = command_parser.parse(command)
        self.assertEqual(result, None)
    def test_acknowledgement_parsing(self):
        settings = OrmucoCacheServerSettings()

        command_parser = CommandParser(settings)

        command = "ACK"
        result = command_parser.parse(command)
        self.assertEqual(result, True)
    def test_invalid_command_parsing(self):
        settings = OrmucoCacheServerSettings()

        command_parser = CommandParser(settings)

        command = "FOOBAR"
        with self.assertRaises(Exception):
            result = command_parser.parse(command)

        command = "NOT A COMMAND"
        with self.assertRaises(Exception):
            result = command_parser.parse(command)
    def test_retrieve_after_store_command_test(self):
        settings = OrmucoCacheServerSettings()

        command_parser = CommandParser(settings)

        store_command = "STR Key [1,2,3]"
        result = command_parser.parse(store_command)
        self.assertEqual(result, True)

        retrieve_command = "RTRV Key"
        result = command_parser.parse(retrieve_command)
        self.assertEqual(result, [1, 2, 3])
Example #7
0
    def test_server_memory_repository_creation(self):
        settings = OrmucoCacheServerSettings()
        repository = RepositoryFactory.build_repository(settings)

        self.assertIsInstance(repository, MemoryRepository)
 def __init__(self, settings=None):
     self.settings = settings if settings else OrmucoCacheServerSettings()
     self.command_parser = CommandParser(self.settings)
     self.server_factory = ServerProtocolFactory(self.command_parser)
     self.peer_factory = PeerProtocolFactory(self.command_parser)