class TestNetworksManager(unittest.TestCase):
    """
    Tests for the NetworksManager
    """
    def setUpClass(self):
        self.mana = NetworkOperatorManager(TMPFILE)
        networks = __import__('resources/extra/networks')
        instances = [getattr(networks, item)() for item in dir(networks)
            if (not item.startswith('__') and item != 'NetworkOperator')]
        return self.mana.populate_networks(instances)
    
    def tearDownClass(self):
        self.mana.close()
        shutil.rmtree(TMPFILE)
    
    def test_lookup_network(self):
        """
        Test that looking up a known netid (21401) works
        """
        network = self.mana.get_network_by_id(21401)
        self.assertEqual(network.name, 'Vodafone')
        self.assertEqual(network.country, 'Spain')
    
    def test_lookup_inexistent_network(self):
        """
        Test that looking up an unknown netid (6002 atm) returns None
        """
        network = self.mana.get_network_by_id(6002)
        self.assertEqual(network, None)
class TestNetworksManager(unittest.TestCase):
    """
    Tests for the NetworksManager
    """
    def setUpClass(self):
        self.mana = NetworkOperatorManager(TMPFILE)
        networks = __import__('resources/extra/networks')
        instances = [
            getattr(networks, item)() for item in dir(networks)
            if (not item.startswith('__') and item != 'NetworkOperator')
        ]
        return self.mana.populate_networks(instances)

    def tearDownClass(self):
        self.mana.close()
        shutil.rmtree(TMPFILE)

    def test_lookup_network(self):
        """
        Test that looking up a known netid (21401) works
        """
        network = self.mana.get_network_by_id(21401)
        self.assertEqual(network.name, 'Vodafone')
        self.assertEqual(network.country, 'Spain')

    def test_lookup_inexistent_network(self):
        """
        Test that looking up an unknown netid (6002 atm) returns None
        """
        network = self.mana.get_network_by_id(6002)
        self.assertEqual(network, None)
 def setUpClass(self):
     self.mana = NetworkOperatorManager(TMPFILE)
     networks = __import__('resources/extra/networks')
     instances = [
         getattr(networks, item)() for item in dir(networks)
         if (not item.startswith('__') and item != 'NetworkOperator')
     ]
     return self.mana.populate_networks(instances)
 def setUpClass(self):
     self.mana = NetworkOperatorManager(TMPFILE)
     networks = __import__('resources/extra/networks')
     instances = [getattr(networks, item)() for item in dir(networks)
         if (not item.startswith('__') and item != 'NetworkOperator')]
     return self.mana.populate_networks(instances)