From fe21f4ed8ab46905eaf7e041a80d533ba17fa187 Mon Sep 17 00:00:00 2001 From: harika siddanathi Date: Fri, 9 Jul 2021 20:51:12 +0530 Subject: [PATCH 01/15] unitTests --- .github/workflows/unitTests.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/unitTests.yml diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml new file mode 100644 index 00000000..164e0217 --- /dev/null +++ b/.github/workflows/unitTests.yml @@ -0,0 +1,30 @@ +name: UnitTests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + name: UnitTests + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: [ '2.4', '2.3', '2.2' ,'2.1' , '2.0' ] + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Ruby ${{ matrix.ruby-version }} + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + - name: Dependencies Installation + run: | + bundle install --without development + - name: Run Tests + run: | + ruby --version + bundle exec rake From d1dbf8823a957791bacffeed566ac3c1265643af Mon Sep 17 00:00:00 2001 From: harika siddanathi Date: Fri, 9 Jul 2021 20:59:27 +0530 Subject: [PATCH 02/15] Update unitTests.yml --- .github/workflows/unitTests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index 164e0217..62cc429f 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -2,7 +2,7 @@ name: UnitTests on: push: - branches: [ master ] + branches: [ unitTests ] pull_request: branches: [ master ] @@ -12,13 +12,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: [ '2.4', '2.3', '2.2' ,'2.1' , '2.0' ] + ruby-version: [ 'ruby-head', '2.3', '2.2' ,'2.1' , '2.0' ] steps: - name: Checkout uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby-version }} - uses: actions/setup-ruby@v1 + uses: actions/setup-ruby@v2 with: ruby-version: ${{ matrix.ruby-version }} - name: Dependencies Installation From a81945d7b9019da64b53254bb19accf46cb323b5 Mon Sep 17 00:00:00 2001 From: harika siddanathi Date: Fri, 9 Jul 2021 21:01:02 +0530 Subject: [PATCH 03/15] Update unitTests.yml --- .github/workflows/unitTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index 62cc429f..a2913129 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -18,7 +18,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby-version }} - uses: actions/setup-ruby@v2 + uses: actions/setup-ruby with: ruby-version: ${{ matrix.ruby-version }} - name: Dependencies Installation From 0c9bc15eb34dbe911c2b23e78fc8455cd6821ac7 Mon Sep 17 00:00:00 2001 From: harika siddanathi Date: Fri, 9 Jul 2021 21:02:22 +0530 Subject: [PATCH 04/15] Update unitTests.yml --- .github/workflows/unitTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index a2913129..2c0de94a 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -18,7 +18,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby-version }} - uses: actions/setup-ruby + uses: actions/setup-ruby@master with: ruby-version: ${{ matrix.ruby-version }} - name: Dependencies Installation From 986d4eeccae11fdc5d8b301edfec8056e0857717 Mon Sep 17 00:00:00 2001 From: harika siddanathi Date: Fri, 9 Jul 2021 21:06:01 +0530 Subject: [PATCH 05/15] Update unitTests.yml --- .github/workflows/unitTests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index 2c0de94a..046008f8 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -12,13 +12,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: [ 'ruby-head', '2.3', '2.2' ,'2.1' , '2.0' ] + ruby-version: [ 'head', '2.3', '2.2' ,'2.1' , '2.0' ] steps: - name: Checkout uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby-version }} - uses: actions/setup-ruby@master + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} - name: Dependencies Installation From 3041163e03a3c2b487150962fd40e4b3f4963021 Mon Sep 17 00:00:00 2001 From: harika siddanathi Date: Fri, 9 Jul 2021 21:08:23 +0530 Subject: [PATCH 06/15] Update unitTests.yml --- .github/workflows/unitTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index 046008f8..1757f46d 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: [ 'head', '2.3', '2.2' ,'2.1' , '2.0' ] + ruby-version: [ 'head', '2.4', '2.3', '2.2' ,'2.1' , '2.0' ] steps: - name: Checkout From 37e4377f64d994ff40038727bcab822b74ce8b89 Mon Sep 17 00:00:00 2001 From: Mohammed Huzaif Date: Thu, 16 Sep 2021 20:27:02 +0530 Subject: [PATCH 07/15] add rexml --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index e82d39c4..675691f6 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,5 @@ group :test do gem 'rspec', '~> 3.0' gem 'simplecov' gem 'json' + gem 'rexml' end From be4a5b13951c438f814d871459565a4c6c2146c7 Mon Sep 17 00:00:00 2001 From: Mohammed Huzaif Date: Thu, 16 Sep 2021 21:02:47 +0530 Subject: [PATCH 08/15] Update unitTests.yml --- .github/workflows/unitTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index 1757f46d..c46b8615 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: [ 'head', '2.4', '2.3', '2.2' ,'2.1' , '2.0' ] + ruby-version: [ 'head', '2.4', '2.3', '2.2' ,'2.1' ] steps: - name: Checkout From cab5e708a8605597fef77824f6c7541c81dc2476 Mon Sep 17 00:00:00 2001 From: Mohammed Huzaif Date: Thu, 16 Sep 2021 21:04:41 +0530 Subject: [PATCH 09/15] Update unitTests.yml --- .github/workflows/unitTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index c46b8615..4e4443bb 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: [ 'head', '2.4', '2.3', '2.2' ,'2.1' ] + ruby-version: [ 'head', '2.4', '2.3', '2.2' ,'2.1', '2.0' ] steps: - name: Checkout From 02c8273b2e3a0247e7a385f308f32afa8c9b0b0d Mon Sep 17 00:00:00 2001 From: Mohammed Huzaif Date: Thu, 16 Sep 2021 21:14:20 +0530 Subject: [PATCH 10/15] Update resource_powerpacks_spec.rb --- spec/resource_powerpacks_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/resource_powerpacks_spec.rb b/spec/resource_powerpacks_spec.rb index 928740b0..bcd5b96d 100644 --- a/spec/resource_powerpacks_spec.rb +++ b/spec/resource_powerpacks_spec.rb @@ -104,7 +104,7 @@ def to_json_list(list_object) .get( '86bbb125-97bb-4d72-89fd-81d5c515b015' ) - response = powerpack.find_numbers('14845733594') + response = powerpack.find_number('14845733594') # response = powerpack.numberpool.numbers.find('14845733594') expect(JSON.parse(to_json(response))) .to eql(JSON.parse(contents)) @@ -122,7 +122,7 @@ def to_json_list(list_object) .get( '86bbb125-97bb-4d72-89fd-81d5c515b015' ) - response = powerpack.add_numbers('14845733594') + response = powerpack.add_number('14845733594') # response = powerpack.numberpool.numbers.add('14845733594') expect(JSON.parse(to_json(response))) .to eql(JSON.parse(contents)) From 758dce19532593e205d97c98a5d79daf82644154 Mon Sep 17 00:00:00 2001 From: Mohammed Huzaif Date: Thu, 16 Sep 2021 21:25:06 +0530 Subject: [PATCH 11/15] Update resource_calls_spec.rb --- spec/resource_calls_spec.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/resource_calls_spec.rb b/spec/resource_calls_spec.rb index 8135e58f..5b07d1d0 100644 --- a/spec/resource_calls_spec.rb +++ b/spec/resource_calls_spec.rb @@ -85,10 +85,7 @@ def to_json_list_live(list_object) expect(JSON.parse(to_json_create(@api.calls .create('+919090909090', ['+919898989898'], - 'http://www.answer.url', - 'POST', - ring_url: 'http://www.ring.url', - ring_method: 'POST')))) + 'http://www.answer.url')))) .to eql(JSON.parse(contents)) compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Call/', method: 'POST', From 0e895d0878702e62bf5bdb4ebcf56f5c35b36a52 Mon Sep 17 00:00:00 2001 From: Mohammed Huzaif Date: Thu, 16 Sep 2021 21:30:44 +0530 Subject: [PATCH 12/15] Update resource_calls_spec.rb --- spec/resource_calls_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/resource_calls_spec.rb b/spec/resource_calls_spec.rb index 5b07d1d0..780796fe 100644 --- a/spec/resource_calls_spec.rb +++ b/spec/resource_calls_spec.rb @@ -85,7 +85,8 @@ def to_json_list_live(list_object) expect(JSON.parse(to_json_create(@api.calls .create('+919090909090', ['+919898989898'], - 'http://www.answer.url')))) + 'http://www.answer.url' + { answer_method: 'POST',ring_url: 'http://www.ring.url', ring_method:'POST'})))) .to eql(JSON.parse(contents)) compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Call/', method: 'POST', From f9c0c3a52f04e05a60ad55de9ef0e73e2311ef83 Mon Sep 17 00:00:00 2001 From: Mohammed Huzaif Date: Thu, 16 Sep 2021 21:32:35 +0530 Subject: [PATCH 13/15] Update resource_calls_spec.rb --- spec/resource_calls_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/resource_calls_spec.rb b/spec/resource_calls_spec.rb index 780796fe..0c8bfd09 100644 --- a/spec/resource_calls_spec.rb +++ b/spec/resource_calls_spec.rb @@ -85,7 +85,7 @@ def to_json_list_live(list_object) expect(JSON.parse(to_json_create(@api.calls .create('+919090909090', ['+919898989898'], - 'http://www.answer.url' + 'http://www.answer.url', { answer_method: 'POST',ring_url: 'http://www.ring.url', ring_method:'POST'})))) .to eql(JSON.parse(contents)) compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Call/', From 798bba1454b1871efacdb7f2b35e61fe9fe63827 Mon Sep 17 00:00:00 2001 From: huzaif-plivo Date: Thu, 18 Nov 2021 00:41:31 +0530 Subject: [PATCH 14/15] test UT --- spec/resource_lookup_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/resource_lookup_spec.rb b/spec/resource_lookup_spec.rb index 850d11fe..8fb50881 100644 --- a/spec/resource_lookup_spec.rb +++ b/spec/resource_lookup_spec.rb @@ -16,5 +16,6 @@ method: "GET", data: nil) expect(response.phone_number).to eql("+14154305555") + puts response end end From 44320090509b88723162bdd68fcdadeee1be1fdf Mon Sep 17 00:00:00 2001 From: huzaif-plivo Date: Fri, 19 Nov 2021 21:40:56 +0530 Subject: [PATCH 15/15] fix ut --- spec/resource_media_spec.rb | 13 +++++++++++++ spec/resource_powerpacks_spec.rb | 24 ++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/spec/resource_media_spec.rb b/spec/resource_media_spec.rb index 8e681b41..c6d1b130 100644 --- a/spec/resource_media_spec.rb +++ b/spec/resource_media_spec.rb @@ -30,6 +30,19 @@ def to_json_list(list_object) offset: 4 }) end + + def to_json(media) + { + api_id: media.api_id, + content_type: media.content_type, + file_name: media.file_name, + size: media.size, + media_id: media.media_id, + upload_time: media.upload_time, + url: media.url, + }.to_json + end + it 'fetches details of a media' do contents = File.read(Dir.pwd + '/spec/mocks/mediaGetResponse.json') mock(200, JSON.parse(contents)) diff --git a/spec/resource_powerpacks_spec.rb b/spec/resource_powerpacks_spec.rb index bcd5b96d..1c66713e 100644 --- a/spec/resource_powerpacks_spec.rb +++ b/spec/resource_powerpacks_spec.rb @@ -10,7 +10,7 @@ def to_json_list(list_object) meta: list_object[:meta], objects: objects_json }.to_json - end + end it 'lists all powerpack' do contents = File.read(Dir.pwd + '/spec/mocks/powerpackListResponse.json') @@ -30,6 +30,21 @@ def to_json_list(list_object) offset: 4 }) end + + def to_json(media) + { + api_id: media.api_id, + application_id: media.application_id, + application_type: media.application_type, + created_on: media.created_on, + local_connect: media.local_connect, + name: media.name, + number_pool: media.number_pool, + sticky_sender: media.sticky_sender, + uuid: media.uuid, + }.to_json + end + it 'fetches details of a powerpack' do contents = File.read(Dir.pwd + '/spec/mocks/powerpackResponse.json') mock(200, JSON.parse(contents)) @@ -189,11 +204,8 @@ def to_json_list(list_object) it 'remove shortcode' do contents = File.read(Dir.pwd + '/spec/mocks/powerpackDelete.json') mock(200, JSON.parse(contents)) - powerpack = @api.powerpacks - .get( - '86bbb125-97bb-4d72-89fd-81d5c515b015' - ) - response = powerpack.remove_tollfree('444444') + powerpack = @api.powerpacks.get("86bbb125-97bb-4d72-89fd-81d5c515b015") + response = powerpack.remove_shortcode('444444') expect(JSON.parse(to_json(response))) .to eql(JSON.parse(contents)) compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Shortcode/444444/'\