Exemplo n.º 1
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"
            })
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)