From 50cba48c7c0c788d8f06132f51fc1cb3039216f1 Mon Sep 17 00:00:00 2001
From: arturlazarenkoemnify <artur.lazarenko@iternal.group>
Date: Mon, 20 Jun 2022 11:31:07 +0200
Subject: [PATCH 01/11] feat: added sonarcloud action

---
 .github/workflows/unit-tests.yml | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 8f33a52..7a6b5a9 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -2,7 +2,10 @@ name: Unit-tests
 on:
   push:
     branches:
-      - '*'
+      - main
+  pull_request:
+      branches:
+        - '*'
 
 jobs:
   build:
@@ -19,4 +22,9 @@ jobs:
         run: pip install -r req.txt
 
       - name: Run tests
-        run: pytest --cov=emnify --cov-fail-under=90
+        run: pytest --cov=emnify --cov-report=xml --cov-branch
+      - name: SonarCloud Scan
+        uses: sonarsource/sonarcloud-github-action@master
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

From fc6c935349a7beb03c272216d594d6c9e10ebde2 Mon Sep 17 00:00:00 2001
From: arturlazarenkoemnify <artur.lazarenko@iternal.group>
Date: Mon, 20 Jun 2022 11:38:07 +0200
Subject: [PATCH 02/11] feat: added sonarcloud project properties

---
 sonar-project.properties | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 sonar-project.properties

diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100644
index 0000000..e9e06a7
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,4 @@
+sonar.projectKey=emnify-sdk-python
+sonar.organization=emnify
+
+sonar.python.coverage.reportPaths=coverage.xml

From ed0af82dbbf7f5422e3e046f4b5fed77fd2ab83d Mon Sep 17 00:00:00 2001
From: arturlazarenkoemnify <artur.lazarenko@iternal.group>
Date: Mon, 20 Jun 2022 11:43:03 +0200
Subject: [PATCH 03/11] changed sonarcloud project properties

---
 sonar-project.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sonar-project.properties b/sonar-project.properties
index e9e06a7..97507b0 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -1,4 +1,4 @@
-sonar.projectKey=emnify-sdk-python
+sonar.projectKey=EMnify_emnify-sdk-python
 sonar.organization=emnify
 
 sonar.python.coverage.reportPaths=coverage.xml

From 03d77482d317fbdd15523df0659ea57f542ac717 Mon Sep 17 00:00:00 2001
From: arturlazarenkoemnify <artur.lazarenko@iternal.group>
Date: Mon, 20 Jun 2022 16:43:28 +0200
Subject: [PATCH 04/11] changed README.md

---
 README.md | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/README.md b/README.md
index b26cdd3..b9bc7e2 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,10 @@
 # EMnify Python SDK
+[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=EMnify_emnify-sdk-python&metric=reliability_rating&token=40a0a09c3aa65d8898ae2b646e8547ecce2ac28d)](https://sonarcloud.io/summary/new_code?id=EMnify_emnify-sdk-python)
+[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=EMnify_emnify-sdk-python&metric=coverage&token=40a0a09c3aa65d8898ae2b646e8547ecce2ac28d)](https://sonarcloud.io/summary/new_code?id=EMnify_emnify-sdk-python)
+[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=EMnify_emnify-sdk-python&metric=sqale_rating&token=40a0a09c3aa65d8898ae2b646e8547ecce2ac28d)](https://sonarcloud.io/summary/new_code?id=EMnify_emnify-sdk-python)
+[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=EMnify_emnify-sdk-python&metric=security_rating&token=40a0a09c3aa65d8898ae2b646e8547ecce2ac28d)](https://sonarcloud.io/summary/new_code?id=EMnify_emnify-sdk-python)
+[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=EMnify_emnify-sdk-python&metric=bugs&token=40a0a09c3aa65d8898ae2b646e8547ecce2ac28d)](https://sonarcloud.io/summary/new_code?id=EMnify_emnify-sdk-python)
+[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=EMnify_emnify-sdk-python&metric=vulnerabilities&token=40a0a09c3aa65d8898ae2b646e8547ecce2ac28d)](https://sonarcloud.io/summary/new_code?id=EMnify_emnify-sdk-python)
 
 Supply your swarm of IoT Devices with cloud connectivity by [EMnify](https://emnify.com).
 Automate your routines with this SDK for Python.  

From b172718efbe3d25dbfb19eabea408727d905d07b Mon Sep 17 00:00:00 2001
From: Mikhail G <mg@rademade.com>
Date: Mon, 20 Jun 2022 18:25:59 +0300
Subject: [PATCH 05/11] debug reports coverage

---
 .github/workflows/unit-tests.yml | 12 ++++++++++--
 sonar-project.properties         |  2 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 7a6b5a9..c92e1ef 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -1,16 +1,18 @@
-name: Unit-tests
+name: Unit-Tests
 on:
   push:
     branches:
       - main
+      # TODO: remove temporary credential
+      - feature/sonarcloud-action
   pull_request:
       branches:
         - '*'
 
 jobs:
   build:
+    name: Run Unit-Tests
     runs-on: ubuntu-latest
-
     steps:
       - name: Cancel Previous Runs
         uses: styfle/cancel-workflow-action@0.9.1
@@ -28,3 +30,9 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+
+      - name: Archive code coverage results
+        uses: actions/upload-artifact@v3
+        with:
+          name: code-coverage-report
+          path: coverage.xml
diff --git a/sonar-project.properties b/sonar-project.properties
index 97507b0..050aa2c 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -1,4 +1,6 @@
 sonar.projectKey=EMnify_emnify-sdk-python
 sonar.organization=emnify
+sonar.sources=emnify
+sonar.tests=tests
 
 sonar.python.coverage.reportPaths=coverage.xml

From 119d8a937b8ab5291dd5370f790b0dbf4a6165ae Mon Sep 17 00:00:00 2001
From: Mikhail G <mg@rademade.com>
Date: Mon, 20 Jun 2022 18:36:29 +0300
Subject: [PATCH 06/11] added coverage config

---
 .coveragerc                      | 6 ++++++
 .github/workflows/unit-tests.yml | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 .coveragerc

diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..00a71ec
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,6 @@
+[run]
+branch=True
+source = .
+
+[report]
+omit = docs/*, tests/*
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index c92e1ef..5a55de1 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -24,8 +24,8 @@ jobs:
         run: pip install -r req.txt
 
       - name: Run tests
-        run: pytest --cov=emnify --cov-report=xml --cov-branch
-      - name: SonarCloud Scan
+        run: pytest --cov-report=xml
+      - name: Export SonarCloud Result
         uses: sonarsource/sonarcloud-github-action@master
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

From b7d5a3269504b41262ae3fc331c809dea709a904 Mon Sep 17 00:00:00 2001
From: Mikhail G <mg@rademade.com>
Date: Mon, 20 Jun 2022 18:43:25 +0300
Subject: [PATCH 07/11] restore coverage flag

---
 .coveragerc                      | 5 +++++
 .github/workflows/unit-tests.yml | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/.coveragerc b/.coveragerc
index 00a71ec..06dc082 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -2,5 +2,10 @@
 branch=True
 source = .
 
+[paths]
+source = .
+
 [report]
 omit = docs/*, tests/*
+
+[xml]
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 5a55de1..9d610b7 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -24,7 +24,7 @@ jobs:
         run: pip install -r req.txt
 
       - name: Run tests
-        run: pytest --cov-report=xml
+        run: pytest --cov=. --cov-report=xml
       - name: Export SonarCloud Result
         uses: sonarsource/sonarcloud-github-action@master
         env:

From d9a3da3f4d11358b909eb1843e2d2349be3b922e Mon Sep 17 00:00:00 2001
From: Mikhail G <mg@rademade.com>
Date: Mon, 20 Jun 2022 18:53:43 +0300
Subject: [PATCH 08/11] remove unnecessary todos

---
 .github/workflows/unit-tests.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 9d610b7..0b84920 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -3,8 +3,6 @@ on:
   push:
     branches:
       - main
-      # TODO: remove temporary credential
-      - feature/sonarcloud-action
   pull_request:
       branches:
         - '*'

From ec143e6f2cc7c905b7cdceca85e7438fa972de2e Mon Sep 17 00:00:00 2001
From: Mikhail G <mg@rademade.com>
Date: Mon, 20 Jun 2022 19:03:37 +0300
Subject: [PATCH 09/11] test coverage drop

---
 .github/workflows/unit-tests.yml |  2 ++
 tests/test_emnify.py             | 36 ++++++++++++++++----------------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 0b84920..9d610b7 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -3,6 +3,8 @@ on:
   push:
     branches:
       - main
+      # TODO: remove temporary credential
+      - feature/sonarcloud-action
   pull_request:
       branches:
         - '*'
diff --git a/tests/test_emnify.py b/tests/test_emnify.py
index cdb3eb3..36daaf6 100644
--- a/tests/test_emnify.py
+++ b/tests/test_emnify.py
@@ -75,24 +75,24 @@ def test_get_device_sms_list(self):
         self.assertGreater(len(sms_instances), 0)
         self.assertIsInstance(sms_instances[0], emnify.devices.list_sms_model)
 
-    @vcr.use_cassette('tests/fixtures/cassettes/get_sim_list.yaml')
-    def test_get_sim_list(self):
-        emnify = emnify_client(app_token=self.token)
-        sims = [i for i in emnify.sim.get_sim_list()]
-        if sims:
-            self.assertIsInstance(sims[0], emnify.sim.get_sim_list_model)
-
-    @vcr.use_cassette('tests/fixtures/cassettes/activate_sim_by_bic_200.yaml')
-    def test_activate_sim_by_one_size_batch_bic_200(self):
-        bics = [  # BIC CODES
-            'valid_bic_code',
-            'invalid_bic_code'
-            ]
-        emnify = emnify_client(app_token=self.token)
-        bic = bics[0]
-        response = emnify.sim.register_sim(bic=bic)
-        self.assertIsInstance(response, list)
-        self.assertIsInstance(response[0], emnify.sim.get_sim_list_model)
+#     @vcr.use_cassette('tests/fixtures/cassettes/get_sim_list.yaml')
+#     def test_get_sim_list(self):
+#         emnify = emnify_client(app_token=self.token)
+#         sims = [i for i in emnify.sim.get_sim_list()]
+#         if sims:
+#             self.assertIsInstance(sims[0], emnify.sim.get_sim_list_model)
+#
+#     @vcr.use_cassette('tests/fixtures/cassettes/activate_sim_by_bic_200.yaml')
+#     def test_activate_sim_by_one_size_batch_bic_200(self):
+#         bics = [  # BIC CODES
+#             'valid_bic_code',
+#             'invalid_bic_code'
+#             ]
+#         emnify = emnify_client(app_token=self.token)
+#         bic = bics[0]
+#         response = emnify.sim.register_sim(bic=bic)
+#         self.assertIsInstance(response, list)
+#         self.assertIsInstance(response[0], emnify.sim.get_sim_list_model)
 
     @vcr.use_cassette('tests/fixtures/cassettes/activate_sim_by_bic_422.yaml')
     def test_activate_sim_by_one_size_batch_bic_422(self):

From 01877f43ae450dbd71a95ec07cb8b6efbcb65f63 Mon Sep 17 00:00:00 2001
From: Mikhail G <mg@rademade.com>
Date: Mon, 20 Jun 2022 19:22:38 +0300
Subject: [PATCH 10/11] tuned verbose

---
 .coveragerc              |  1 -
 sonar-project.properties |  1 +
 tests/test_emnify.py     | 36 ++++++++++++++++++------------------
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/.coveragerc b/.coveragerc
index 06dc082..810b6b7 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -8,4 +8,3 @@ source = .
 [report]
 omit = docs/*, tests/*
 
-[xml]
diff --git a/sonar-project.properties b/sonar-project.properties
index 050aa2c..ef86178 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -2,5 +2,6 @@ sonar.projectKey=EMnify_emnify-sdk-python
 sonar.organization=emnify
 sonar.sources=emnify
 sonar.tests=tests
+sonar.verbose=true
 
 sonar.python.coverage.reportPaths=coverage.xml
diff --git a/tests/test_emnify.py b/tests/test_emnify.py
index 36daaf6..cdb3eb3 100644
--- a/tests/test_emnify.py
+++ b/tests/test_emnify.py
@@ -75,24 +75,24 @@ def test_get_device_sms_list(self):
         self.assertGreater(len(sms_instances), 0)
         self.assertIsInstance(sms_instances[0], emnify.devices.list_sms_model)
 
-#     @vcr.use_cassette('tests/fixtures/cassettes/get_sim_list.yaml')
-#     def test_get_sim_list(self):
-#         emnify = emnify_client(app_token=self.token)
-#         sims = [i for i in emnify.sim.get_sim_list()]
-#         if sims:
-#             self.assertIsInstance(sims[0], emnify.sim.get_sim_list_model)
-#
-#     @vcr.use_cassette('tests/fixtures/cassettes/activate_sim_by_bic_200.yaml')
-#     def test_activate_sim_by_one_size_batch_bic_200(self):
-#         bics = [  # BIC CODES
-#             'valid_bic_code',
-#             'invalid_bic_code'
-#             ]
-#         emnify = emnify_client(app_token=self.token)
-#         bic = bics[0]
-#         response = emnify.sim.register_sim(bic=bic)
-#         self.assertIsInstance(response, list)
-#         self.assertIsInstance(response[0], emnify.sim.get_sim_list_model)
+    @vcr.use_cassette('tests/fixtures/cassettes/get_sim_list.yaml')
+    def test_get_sim_list(self):
+        emnify = emnify_client(app_token=self.token)
+        sims = [i for i in emnify.sim.get_sim_list()]
+        if sims:
+            self.assertIsInstance(sims[0], emnify.sim.get_sim_list_model)
+
+    @vcr.use_cassette('tests/fixtures/cassettes/activate_sim_by_bic_200.yaml')
+    def test_activate_sim_by_one_size_batch_bic_200(self):
+        bics = [  # BIC CODES
+            'valid_bic_code',
+            'invalid_bic_code'
+            ]
+        emnify = emnify_client(app_token=self.token)
+        bic = bics[0]
+        response = emnify.sim.register_sim(bic=bic)
+        self.assertIsInstance(response, list)
+        self.assertIsInstance(response[0], emnify.sim.get_sim_list_model)
 
     @vcr.use_cassette('tests/fixtures/cassettes/activate_sim_by_bic_422.yaml')
     def test_activate_sim_by_one_size_batch_bic_422(self):

From 47a06adca1afd19bcf40fcd904821b4f16d79af5 Mon Sep 17 00:00:00 2001
From: Mikhail G <mg@rademade.com>
Date: Mon, 20 Jun 2022 19:30:34 +0300
Subject: [PATCH 11/11] rollback testing trigger

---
 .github/workflows/unit-tests.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 9d610b7..0b84920 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -3,8 +3,6 @@ on:
   push:
     branches:
       - main
-      # TODO: remove temporary credential
-      - feature/sonarcloud-action
   pull_request:
       branches:
         - '*'
