Beispiel #1
0
    def test_setProvider_duplicate(self):
        nc = NetworkController()

        nc.truncateProviders("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addProvider(
            "AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
                "id": "a",
                "name": "b",
                "address": "c",
                "city": "d",
                "state": "e",
                "zip": "f"
            })
        nc.addProvider(
            "AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
                "id": "b",
                "name": "b",
                "address": "c",
                "city": "d",
                "state": "e",
                "zip": "f"
            })
        response = nc.setProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a",
                                  {"id": "b"})
        self.assertEqual(response.error, consts.ERROR_DUPLICATE_ID)
Beispiel #2
0
    def test_setProvider_good(self):
        nc = NetworkController()
        data = {
            "id": "a",
            "name": "b",
            "address": "c",
            "city": "d",
            "state": "e",
            "zip": "f"
        }

        nc.truncateProviders("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        nc.setProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a", {"name": "c"})
        response = nc.getProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a")
        self.assertEqual(response.error, consts.NO_ERROR)
        self.assertEqual(
            response.payload, {
                "id": "a",
                "name": "c",
                "address": "c",
                "city": "d",
                "state": "e",
                "zip": "f"
            })
Beispiel #3
0
    def test_getProvider_nonexistent(self):
        nc = NetworkController()
        data = {
            "id": "a",
            "name": "b",
            "address": "c",
            "city": "d",
            "state": "e",
            "zip": "f"
        }

        nc.truncateProviders("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        response = nc.getProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "b")
        self.assertEqual(response.error, consts.ERROR_NONEXISTENT_ENTRY)
Beispiel #4
0
    def test_getProvider_unauthorized(self):
        nc = NetworkController()
        data = {
            "id": "a",
            "name": "b",
            "address": "c",
            "city": "d",
            "state": "e",
            "zip": "f"
        }

        nc.truncateProviders("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        response = nc.getProvider("asdf", "a")
        self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
Beispiel #5
0
    def test_removeProvider_unauthorized(self):
        nc = NetworkController()

        nc.truncateProviders("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addProvider(
            "AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
                "id": "a",
                "name": "b",
                "address": "c",
                "city": "d",
                "state": "e",
                "zip": "f"
            })
        response = nc.removeProvider("DDPR0TG8EF760QR2J7IUF3UFIRXXL4E3", "a")
        self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)

        response = nc.removeProvider("asd", "a")
        self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
Beispiel #6
0
    def test_removeProvider_good(self):
        nc = NetworkController()

        nc.truncateProviders("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addProvider(
            "AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
                "id": "a",
                "name": "b",
                "address": "c",
                "city": "d",
                "state": "e",
                "zip": "f"
            })
        response = nc.removeProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a")
        self.assertEqual(response.error, consts.NO_ERROR)

        response = nc.getProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a")
        self.assertEqual(response.error, consts.ERROR_NONEXISTENT_ENTRY)
Beispiel #7
0
    def test_addProvider_incomplete(self):
        nc = NetworkController()
        data = {
            "id": "a",
            "name": "b",
            "address": "c",
            "city": "d",
            "state": "e"
        }

        nc.truncateProviders("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        response = nc.addProvider("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        self.assertEqual(response.error,
                         consts.ERROR_FAILED_DATABASE_ADD_INCOMPLETE_DATA)