Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to see testing coverage #12

Merged
merged 37 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
afe8cef
changed import statements in testing
akuljos Jul 21, 2021
fd26d16
added lines in .travis.yml for analyzing test coverage
Jul 15, 2021
ee5edaf
added testing for 3 main delete files
Jul 23, 2021
e43809b
fixed some errors in the test files
Jul 23, 2021
4ee9220
updated imports for new project format
Jul 23, 2021
f680a7c
added tests for input of no on delete
Jul 26, 2021
09f242c
added initial tests for functions.py
Jul 26, 2021
c32d6db
added test enviroment file
Jul 26, 2021
7cbdf30
pushing up current code for collaboration purposes
akuljos Jul 28, 2021
ef4fe11
still want to add some asserts but this is the basic layout of test_i…
Jul 29, 2021
daa076b
wrote a ton of tests for certcreate_iks.py
akuljos Jul 28, 2021
e2c2d46
added missing cert_name parameter from SecretCertificateCreator objec…
akuljos Jul 28, 2021
6e1ae85
fixed imports
akuljos Jul 29, 2021
ae3d691
fixed more imports
akuljos Jul 29, 2021
d445658
added namespace attribute to some mock classes
akuljos Jul 29, 2021
556127e
added some more missing args to the mock classes
akuljos Jul 29, 2021
29459bf
added refresh_token attribute to mock token
akuljos Jul 29, 2021
dc8e9b3
changed .travis.yml to install kubernetes
Jul 29, 2021
425e90d
trying sudo install of kubectl
Jul 29, 2021
39a637f
wrote a ton of tests for certcreate_iks.py
akuljos Jul 28, 2021
37acc61
added missing cert_name parameter from SecretCertificateCreator objec…
akuljos Jul 28, 2021
6ae3b5c
fixed incorrect path in mock create_terraform_workspace
Jul 30, 2021
d5a8230
adding travis file for testing integration
Jun 16, 2021
af617e3
updated .travis.yml
Jun 16, 2021
73a2776
working on creating basic functionality tests
Jun 17, 2021
528a450
restructured project for unit testing
Jun 19, 2021
ac1c253
changed the setup of test files and added return to the creation files
Jun 24, 2021
76b2ac1
implemented initial mock method for API testing
Jun 25, 2021
ba48a45
pushing initial edge function tests
Jun 25, 2021
6b60dbc
fixed errors in testing and the return object in create_edge_function.py
Jun 25, 2021
6d07be4
created a mock model and test for the DNS class
Jun 25, 2021
d77d10b
wrote the tests for the DNS creator
Jun 28, 2021
a659382
Merge branch 'master' into coverage-tests
akuljos Aug 3, 2021
629ff35
fixed local branch and fixed failing tests
Aug 4, 2021
0b983d8
finalized testing for iks ready for review
Aug 4, 2021
86524f2
Merge branch 'master' into coverage-tests
akuljos Aug 4, 2021
761a606
updated testing to take into account commented out portions of iks.py
Aug 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@ python:
install:
- pip3 install -r requirements.txt
- pip3 install -e .
- pip3 install pytest
- pip3 install pytest-cov
- pip3 install coveralls
- pip3 install kubernetes
- curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
script:
- pytest
- pytest --cov=./
after_success:
- coveralls
5 changes: 4 additions & 1 deletion src/ce/delete_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import requests
from src.common.functions import Color

def get_input(text):
return input(text)

class DeleteEdge:
def __init__(self, crn: str, zone_id: str, cis_domain: str, apikey: str, token: str) -> None:
self.crn = crn
Expand All @@ -11,7 +14,7 @@ def __init__(self, crn: str, zone_id: str, cis_domain: str, apikey: str, token:
self.token = token

def delete_edge(self):
execute = input("Delete edge function? Input 'y' or 'yes' to execute: ").lower()
execute = get_input("Delete edge function? Input 'y' or 'yes' to execute: ").lower()
if execute == 'y' or execute == 'yes':
action_name = self.cis_domain.replace('.','-')
#token = self.request_token(self.apikey)
Expand Down
11 changes: 7 additions & 4 deletions src/ce/delete_glb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
from ibm_cloud_sdk_core.api_exception import ApiException
from src.common.functions import Color

def get_input(text):
return input(text)

class DeleteGLB:
def __init__(self, crn: str, zone_id: str, endpoint: str, cis_domain: str) -> None:
self.crn = crn
self.zone_id = zone_id
self.endpoint = endpoint
self.cis_domain = cis_domain
self.cis_domain = cis_domain

def delete_glb(self):
# delete the glb
execute_glb = input("Delete global load balancer? Input 'y' or 'yes' to execute: ").lower()
execute_glb = get_input("Delete global load balancer? Input 'y' or 'yes' to execute: ").lower()
if execute_glb == 'y' or execute_glb == 'yes':
globalLoadBalancer = GlobalLoadBalancerV1.new_instance(
crn=self.crn, zone_identifier=self.zone_id, service_name="cis_services")
Expand All @@ -40,7 +43,7 @@ def delete_glb(self):

if keepgoing:
# delete the origin pool
execute_origin = input("Delete origin pool? Input 'y' or 'yes' to execute: ").lower()
execute_origin = get_input("Delete origin pool? Input 'y' or 'yes' to execute: ").lower()
if execute_origin == 'y' or execute_origin == 'yes':
globalLoadBalancerPools = GlobalLoadBalancerPoolsV0.new_instance(
crn=self.crn, service_name="cis_services")
Expand All @@ -64,7 +67,7 @@ def delete_glb(self):

if keepgoing:
# delete the linked health check
execute_monitor = input("Delete health check monitor? Input 'y' or 'yes' to execute: ").lower()
execute_monitor = get_input("Delete health check monitor? Input 'y' or 'yes' to execute: ").lower()
if execute_monitor == 'y' or execute_monitor == 'yes':

cert = GlobalLoadBalancerMonitorV1.new_instance(
Expand Down
5 changes: 4 additions & 1 deletion src/common/delete_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from ibm_cloud_sdk_core.api_exception import ApiException
from src.common.functions import Color

def get_input(text):
return input(text)

class DeleteDNS:
def __init__(self, crn: str, zone_id: str, endpoint: str, cis_domain: str) -> None:
self.crn = crn
Expand All @@ -12,7 +15,7 @@ def __init__(self, crn: str, zone_id: str, endpoint: str, cis_domain: str) -> No
self.cis_domain = cis_domain

def delete_dns(self):
execute = input("Delete DNS Records? Input 'y' or 'yes' to execute: ").lower()
execute = get_input("Delete DNS Records? Input 'y' or 'yes' to execute: ").lower()
if execute == 'y' or execute == 'yes':
# create instance
record = DnsRecordsV1.new_instance(
Expand Down
2 changes: 2 additions & 0 deletions src/common/dns_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def create_records(self):

return (root_record, www_record)

return (root_record, www_record)

def create_root_record(self, record, record_type, root_name):
root_record = record.create_dns_record(type=record_type, name=root_name, content=self.content, proxied=True)
return root_record
Expand Down
9 changes: 4 additions & 5 deletions src/root_terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ variable pool_name {
}

variable cluster_id {
type = string
description = "Cluster ID of the IKS instance"
type = string
description = "Cluster ID of the IKS instance"
}

variable standard {
type = bool
description = "Determines whether the CIS instance is using the Standard Plan"
type = string
type = bool
description = "Determines whether the CIS instance is using the Standard Plan"
}

variable create_ce {
Expand Down
8 changes: 8 additions & 0 deletions test_var.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CRN="test_crn"
ZONE_ID="test_zone_id"
API_ENDPOINT="www.test_api_endpoint.com"
CIS_SERVICES_APIKEY="test_api_key"
CIS_NAME="test_instance_name"
RESOURCE_GROUP="test-resource-group"
APP_DOMAIN="test_app_url.com"
CIS_DOMAIN="gcat-interns-test.com"
39 changes: 0 additions & 39 deletions tests/intro_tests.py

This file was deleted.

Loading