Skip to content

Commit

Permalink
tests.py: ignore tests for mode of .gitkeep files
Browse files Browse the repository at this point in the history
  • Loading branch information
vasiliyk committed May 27, 2024
1 parent 4cf6810 commit d0c19a9
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import flask
except ImportError:
flask = None
import mocks
import tcollector


Expand Down Expand Up @@ -63,8 +62,8 @@ def test_bad_float(self):
This can happen if a specific collector is buggy.
"""
thread = tcollector.ReaderThread(1, 10, True) # pylint:disable=no-member
collector = tcollector.Collector("c", 1, "c") # pylint:disable=no-member
thread = tcollector.ReaderThread(1, 10, True) # pylint:disable=no-member
collector = tcollector.Collector("c", 1, "c") # pylint:disable=no-member
for line in ["xxx", "mymetric 123 Value a=b"]:
thread.process_line(collector, line)
self.assertEqual(thread.readerq.qsize(), 0)
Expand All @@ -73,8 +72,8 @@ def test_bad_float(self):

def test_ok_lines(self):
"""Good lines are passed on to OpenTSDB."""
thread = tcollector.ReaderThread(1, 10, True) # pylint:disable=no-member
collector = tcollector.Collector("c", 1, "c") # pylint:disable=no-member
thread = tcollector.ReaderThread(1, 10, True) # pylint:disable=no-member
collector = tcollector.Collector("c", 1, "c") # pylint:disable=no-member
for line in ["mymetric 123.24 12 a=b",
"mymetric 124 12.7 a=b",
"mymetric 125 12.7"]:
Expand All @@ -91,17 +90,21 @@ def test_collectorsAccessRights(self):
"""Test of collectors access rights, permissions should be 0100755."""

def check_access_rights(top):
for f in os.listdir(top):
pathname = os.path.join(top, f)
for file in os.listdir(top):
pathname = os.path.join(top, file)
mode = os.stat(pathname).st_mode

if S_ISDIR(mode):
# directory, recurse into it
check_access_rights(pathname)
elif S_ISREG(mode):
# file, skip .gitkeep files that keep empty dirs in git
if file == '.gitkeep':
continue

# file, check permissions
permissions = oct(os.stat(pathname)[ST_MODE])
self.assertEqual("0o100755", permissions)
self.assertEqual("0o100755", permissions, f'file: {pathname}')
else:
# unknown file type
pass
Expand Down Expand Up @@ -146,8 +149,8 @@ def test_endtoend(self):
thread.setDaemon(True)
thread.start()

r = tcollector.urlopen("http://127.0.0.1:32025").read() # pylint:disable=no-member
self.assertEqual(json.loads(r), [c.to_json() for c in collectors.values()])
result = tcollector.urlopen("http://127.0.0.1:32025").read() # pylint:disable=no-member
self.assertEqual(json.loads(result), [c.to_json() for c in collectors.values()])


@unittest.skipUnless(flask, "Flask not installed")
Expand All @@ -169,7 +172,7 @@ def send_query_with_response_code(self, response_code):
"""
self.run_fake_opentsdb(response_code)
reader = tcollector.ReaderThread(1, 10, True) # pylint:disable=no-member
sender = tcollector.SenderThread( # pylint:disable=no-member
sender = tcollector.SenderThread( # pylint:disable=no-member
reader, False, [("localhost", 4242)], False, {},
http=True, http_api_path="api/put"
)
Expand Down Expand Up @@ -279,4 +282,5 @@ def test_doublePickTwoConnections(self):
'collectors')
tcollector.setup_python_path(cdir) # pylint: disable=maybe-no-member
tcollector.populate_collectors(cdir) # pylint: disable=maybe-no-member
sys.exit(unittest.main())

unittest.main()

0 comments on commit d0c19a9

Please sign in to comment.