@@ -52,6 +52,9 @@ def setUp(self):
5252 self .nodes_empty_json = StringIO ('' )
5353
5454 def test_count_matching_mac (self ):
55+ '''
56+ Confirms MAC conflection is counted correctly.
57+ '''
5558 count_result = rec_lookup .count_matching_mac ("12345678" )
5659 self .assertEqual (count_result , 0 )
5760
@@ -86,10 +89,13 @@ def test_count_matching_mac(self):
8689
8790 mock_open .assert_called ()
8891
89- class Test_LookUp_AccessRequest (unittest .TestCase ):
92+ class TestLookUpAccessRequest (unittest .TestCase ):
9093 '''Access Request Tests'''
9194
9295 def setUp (self ):
96+ '''
97+ Collection of JSON used for testing.
98+ '''
9399 self .system_json = StringIO (
94100 '''{
95101 "serial": "536780dfe639468e8e23fc568006950d",
@@ -265,6 +271,9 @@ def setUp(self):
265271 )
266272
267273 def test_files_opened (self ):
274+ '''
275+ Confirms that all the files are correctly opened and read.
276+ '''
268277 with patch ('modules.rec_lookup.open' ) as mock_open :
269278 mock_open .side_effect = [
270279 self .system_json ,
@@ -274,10 +283,13 @@ def test_files_opened(self):
274283 self .permissions_json , # Opened from get_group_details function.
275284 ]
276285
277- rec_lookup .access_request (313131 , '0011223344556677' )
286+ self . assertAlmostEqual ( rec_lookup .access_request (313131 , '0011223344556677' ), 2 )
278287 mock_open .assert_called ()
279288
280289 def test_mac_to_id (self ):
290+ '''
291+ Confirms that the mac address is converted to the node id.
292+ '''
281293 with patch ('modules.rec_lookup.open' ) as mock_open :
282294 mock_open .return_value = self .nodes_json
283295
@@ -293,6 +305,9 @@ def test_mac_to_id(self):
293305 self .assertEqual (node_id , '9911223344556677' )
294306
295307 def test_is_owner (self ):
308+ '''
309+ Confirms that the owner check function returns the correct value.
310+ '''
296311 with patch ('modules.rec_lookup.open' ) as mock_open :
297312 mock_open .return_value = self .owners_json
298313
@@ -308,6 +323,9 @@ def test_is_owner(self):
308323 self .assertFalse (owner )
309324
310325 def test_get_details (self ):
326+ '''
327+ Verifies that the correct details are returned.
328+ '''
311329 with patch ('modules.rec_lookup.open' ) as mock_open :
312330 mock_open .return_value = self .members_json
313331
@@ -323,6 +341,9 @@ def test_get_details(self):
323341 self .assertFalse (user ['found' ])
324342
325343 def test_get_group_details (self ):
344+ '''
345+ Verifies that the correct details are returned.
346+ '''
326347 with patch ('modules.rec_lookup.open' ) as mock_open :
327348 mock_open .return_value = self .permissions_json
328349
@@ -338,6 +359,9 @@ def test_get_group_details(self):
338359 self .assertFalse (group ['found' ])
339360
340361 def test_access_request_combinations (self ):
362+ '''
363+ Checks that the access request function returns the correct values.
364+ '''
341365 with patch ('modules.rec_lookup.open' ) as mock_open :
342366 mock_open .side_effect = [
343367 self .system_json ,
0 commit comments